package com.example.topguli;

import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeUnit;

public class CollectionTest {
    public static void main(String[] args) {
        ArrayList<Integer> integers = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        TreeSet<Integer> sets = new TreeSet<>();
        CopyOnWriteArraySet copyOnWriteArraySet = new CopyOnWriteArraySet();
        Set<Integer> integers1 = Collections.synchronizedSet(sets);
        new Thread(()->{
                for (Integer i1 = 0; i1 < 100; i1++) {
                    sets.add(i1);
                }
            }).start();

        new Thread(()->{
            for (Integer i1 = 100; i1 < 200; i1++) {
                sets.add(i1);
            }
        }).start();

        new Thread(()->{
            for (Integer i1 = 200; i1 < 300; i1++) {
                sets.add(i1);
            }
        }).start();
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(sets.size());
    }
}
